<%@ page language="java" import="njust.domain.*,java.util.*,njust.dao.*,njust.dao.impl.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>


<script src="./jquery.js"></script>
<link rel="stylesheet" href="./bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="./bootstrap/css/bootstrap-theme.min.css">
<script src="./bootstrap/js/bootstrap.min.js" async></script>


<link rel="stylesheet" href="./css/goods_detail.css">
<link rel="stylesheet" href="./css/pic.css">
<script src="./js/message.js" async></script>
<script src="./js/good_detail.js"></script>
<script type="text/javascript">
	var t;
	var speed = 1;//图片切换速度
	var nowlan = 0;//图片开始时间
	function changepic() {
		var $di = $("#SwitchBigPic");
		var imglen = $di.find("div").length;
		$di.find("div").hide();
		$di.find("div").eq(nowlan).show();
		nowlan = nowlan + 1 == imglen ? 0 : nowlan + 1;
		t = setTimeout("changepic()", speed * 2000);

	}
	onload = function() {
		changepic();
	};
	$(document).ready(function() {
		//鼠标在按钮上悬停让切换暂停
		$("img[name='button0']").each(function(i) {
			$(this).hover(function() {
				clearInterval(t);
				var $di = $("#SwitchBigPic");
				$di.find("div").hide();
				//$di.find("div").eq($di.find("div").length - 1).show();
				$di.find("div").eq(i).show();
			}, function() {
				changepic();
			});
		});
	});
</script>
</head>

<body>
	<jsp:include page="./head.jsp"></jsp:include>
	<div id="content_container">
		<div id="top_nav">
			<ul>
				<li>
					<h5>卖家:</h5> <span><strong>${goods.user.username}</strong></span>
				</li>
				<li>
					<h5>宝贝浏览次数</h5> <span>${goods.pageview}</span>
				</li>
				<li>
					<h5>最近编辑</h5> <span>${goods.time}</span>
				</li>
				<li class="jubao"><a href="#">举报该宝贝</a></li>
			</ul>
		</div>
		<div style="height:700px;">
			<div class="foucebox" style="display:inline-block; float:left">

				<div id="SwitchBigPic" class="f_s_box">
					<c:forEach items="${imgList}" var="img" varStatus="status">
						<div id="showDiv_${status.index }"
							style="width: 650px;height: 560px;display: block; position: absolute; left: 0px; top: 0px; ">
							<a href="#"><img id="bigpic_0"
								style="width: 650px; height: 560px;" src="${img.url}"></a> <span
								id="title_bg_0" class="f_s_bg" style="display: block;"></span>
							<p class="f_s_txt">
								<a id="title_0" href="#" style="display: block;">        </a>
							</p>
						</div>
					</c:forEach>
				</div>

				<div class="scrollimg_tigger" style="margin-top: 5px">
					<div id="bigHover" class="scrollimg_tigger_hover"
						style="margin-left: 57px;"></div>
					<c:forEach items="${imgList}" var="img" varStatus="status">
						<img style="width: 90px;height: 82px;" name="button0"
							src="${img.url}">
					</c:forEach>
					<ul class="scrollimg_tigger_link">
						<c:forEach items="${imgList}" var="img" varStatus="status">
							<li><a id="big_pic_nav_${status.index }"
								onclick="document.body.focus()" class=""></a></li>
						</c:forEach>
					</ul>
				</div>
			</div>

			<div id="goods_detail">
				<input type="hidden" name="goods.id" />
				<h1>${goods.goodname }</h1>
				<ul>
					<li><span>价格：</span> <span class="price">￥${goods.price }</span>
					</li>
					<li>
						<p>
						<c:choose>
							<c:when test="${goods.bargin!=false }">
							可以讲价
							</c:when>
							<c:otherwise>
							拒绝讲价
							</c:otherwise>
						</c:choose>
					
						</p>
					</li>
					<li style="display:none">该商品拒绝讲价！</li>
				</ul>
				<hr>
				<ul>
					<li><span>成&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp色：</span>
					<span>
						<c:choose>
                        <c:when test="${goods.agingdegree==10 }">全新</c:when>
                        <c:when test="${goods.agingdegree==9 }">九成新</c:when>
                        <c:when test="${goods.agingdegree==8 }">八成新</c:when>
                        <c:when test="${goods.agingdegree==7 }">七成新</c:when>
                        <c:when test="${goods.agingdegree==6 }">六成新</c:when>
                        <c:when test="${goods.agingdegree==5 }">五成新</c:when>
                        <c:when test="${goods.agingdegree==4 }">四城新</c:when>
                        <c:when test="${goods.agingdegree==3 }">三成新</c:when>
                        <c:when test="${goods.agingdegree==2 }">两层新</c:when>
 						<c:when test="${goods.agingdegree==1 }">一层新</c:when>
						</c:choose>			
					</span>
					</li>
					<li><span>所在大学：</span> <span>南京理工大学</span></li>
					<li><span>联系方式：</span>
						<div>
							<span>QQ:</span> <span>${goods.user.qq}</span> <br> <span>电话:</span>
							<span>${goods.user.phonenumber}</span>
						</div></li>
					<li></li>
				</ul>
			</div>
		</div>


		<div id="describe_message">
			<div class="menu">
				<ul>
					<li id="menu_describe" class="active">宝贝介绍</li>
					<li id="menu_message" class="">留言${goods.message.size() }</li>
				</ul>
			</div>
			<div class="describe" style="display:block">
				<h3>
					<b>宝贝介绍</b>
				</h3>
				<div class="describe_content">
					<p style="font-size:18px;line-height:2;">
					
					${goods.describe }
					
					</p>
				</div>
              <input id="goodsids" type="hidden" value="${goods.id }">
			</div>


			<div class="message clearfix">
				<h3>
					<b>留言</b>
				</h3>
				<div class="add_message clearfix">
					<div class="message_user">
						<img src="./img/head.jpg" alt="">
					</div>
					<div class="message_add">
						<textarea id="contents"  placeholder="我也插句话..." name="message.content"></textarea>
					</div>
					<button type="button" id="comment" class="btn btn-info" style="float:right">
						评论</button>
				</div>
				<input id="username" type="hidden" value="${sessionScope.user.username}">
				<div id="allmessage" class="all_message">
				
				
				
					<% 
						List<User> user = new ArrayList<User>();
						List<Message> message = new ArrayList<Message>();
						user = (List<User>)request.getAttribute("userList");
						message.addAll(((Goods)request.getAttribute("goods")).getMessage());
						Message msg = new Message();
						for (int i = message.size()-1; i >= 0; i--)
						{
							msg = message.get(i);
					%>
					
					<div class="message_item">
						<img src="./img/head.jpg" alt="">
						<div>
							<p><%=user.get(i).getUsername() %>：<%=msg.getContent() %></p>
							<p><%=msg.getTime() %></p>
						</div>
						<span class="respond_btn">回复</span>
					</div>

					
					
					<div class="respond clearfix" style="display: none;">
						<div class="respond_user">
							<img src="./img/head.jpg" alt="">
						</div>
						<div class="respond_message">
							<textarea placeholder="回复@<%=user.get(i).getUsername() %>"></textarea>
						</div>
						<button type="button" class="btn btn-info btn-sm"
							style="float:right;margin-right:20px;">发表</button>
					</div>
					<%} %>
					
					
					
					<div class="respond clearfix" style="display: none;">
						<div class="respond_user">
							<img src="./img/head.jpg" alt="">
						</div>
						<div class="respond_message">
							<textarea placeholder="回复@丁子祥"></textarea>
						</div>
						<button type="button" class="btn btn-info btn-sm"
							style="float:right;margin-right:20px;">评论</button>
					</div>
				</div>

				<div style="height: 100px"></div>
			</div>
		</div>
	</div>

</body>

</html>
